/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ttt.nor2.db;

import com.ttt.nor2.util.ExceptionUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Hashtable;
import org.apache.log4j.Logger;

/**
 *
 * @author anuphabm
 */
public class HtbNcen {
    private Logger logger = Logger.getLogger(HtbNcen.class);
    private Connection conn;

    public HtbNcen(Connection conn) {
        this.conn = conn;
        logger.debug("Start class load data Ncen...");
    }

    public Hashtable loadNcen(){
        Hashtable htb = new Hashtable();

        String sql = "select * from ncen";
        try {
            PreparedStatement pstmt = conn.prepareStatement(sql);
            ResultSet rs = pstmt.executeQuery();

            while (rs.next()) {
                Ncen n = new Ncen();
                //logger.debug("[" + rs.getString("sendid") + "][" + rs.getString("sendname") + "]");
                n.setNcen_code(rs.getInt("ncen_code"));
                n.setProvince_id(rs.getInt("province_id"));
                htb.put(rs.getString("ncen_name"),n);
            }

        } catch (SQLException ex) {
            logger.error("Exception load sender error..." + ExceptionUtil.getStackTrace(ex));
        }
        return htb;
    }

}
